home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / C and C++ / Libraries / SAT / SATcollision ƒ / SATcollision.p < prev    next >
Encoding:
Text File  |  1993-09-19  |  1.3 KB  |  53 lines  |  [TEXT/PJMM]

  1. {*****************************}
  2. {********* SAT Collision **********}
  3. {*****************************}
  4.  
  5. {A SAT demo that is slightly over SATminimal, demonstrating the simplest}
  6. {collision handling based on the kind field (KindCollision).}
  7.  
  8. program SATcollision;
  9.  
  10.     uses
  11.         SAT, sMrEgghead, sApple;
  12.  
  13.     var
  14.         gameWind: WindowPtr;
  15.         ignoreSp: SpritePtr;
  16.         l: longint;
  17.         p: Point;
  18. begin
  19. {Standard Inits are done by Think Pascal.}
  20.  
  21. {Initialize SAT}
  22.     ConfigureSAT(true, VPositionSort, KindCollision, 32);
  23.     gameWind := InitSAT(128, 129, 512, 322);
  24.  
  25. {Initialize sprite units}
  26.     initMrEgghead;
  27.     initApple;
  28.  
  29. {Show and update the window}
  30.     ShowWindow(gameWind);
  31.     SelectWindow(gameWind);
  32.     PeekOffscreen;
  33.  
  34. {Make sprites}
  35.     GetMouse(p); {We get the mouse position in order to put Mr Egghead under it immediately}
  36.     ignoreSp := NewSprite(0, p.h, p.v, @HandleMrEgghead, @SetupMrEgghead, nil);
  37.     ignoreSp := NewSprite(0, 0, Rand(offSizeV - 32), @HandleApple, @SetupApple, nil);
  38.  
  39.     HideCursor;
  40.  
  41.     repeat
  42.         l := TickCount;
  43.         RunSAT(true); {Run a frame of animation}
  44.         while l > TickCount - 3 do {Speed limit}
  45.             ;
  46.  
  47. {Start a new apple once in a while}
  48.         if Rand(40) = 1 then
  49.             ignoreSp := NewSprite(0, 0, Rand(offSizeV - 32), @HandleApple, @SetupApple, nil);
  50.     until Button;
  51.     ShowCursor;
  52.     SATSoundShutUp; {Always make sure the sound channel is de-allocated!}
  53. end.